import MD5 from 'js-md5'
// 生成签名
const strToBinary = (str) => {
  // console.log(str);
  const encodeURIStr = encodeURIComponent(str)
  // console.log(encodeURIStr);
  const result = []
  for (let i = 0; i < encodeURIStr.length; i++) {
    const item = encodeURIStr.charAt(i)
    const binaryStr = item.charCodeAt()
    result.push(binaryStr)
  }
  return result
}
const createSign = (str) => {
  // 字符串转二进制
  const binaryArray = strToBinary(str)
  // console.log(binaryArray)
  // 二进制排序
  binaryArray.sort((a, b) => a - b)
  // console.log(binaryArray)
  // MD5加密
  return MD5(binaryArray)
}
export { createSign }
